<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link href="layui/css/layui.css" rel="stylesheet">
    <script src="layui/layui.js"></script>
    <!--增加的ajax数据-->
    <script type="text/javascript">
    layui.use(['form'],function (){
        var form = layui.form;
        var $ = layui.jquery;
        form.on('submit(addbroker)',function(obj){
            console.log(obj.field);
            $.ajax({
                url:"insertBroker",
                type:"get",
                data:obj.field,
                dataType:"text",
                contentType:"application/x-www-form-urlencoded",//内容类型  form 表单的
                success:function(msg){
                    if(msg==="增加成功"){
                        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                        parent.layer.close(index); //再执行关闭
                    }
                }
            });
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });



      $.getJSON("selectName",function (d){
            console.log("d&ndash;&gt;",d)

            var list = d.data;

            var str = "<option value=''></option>";
            for(var i=0;i<list.length;i++){
                str+="<option value=\""+list[i].userRoleId+"\">"+list[i].userRoleName+"</option>"
            }
            $("#usrRoleId").html(str)
            form.render("select")
        })
    })
</script>
<!--ajax数据结束-->
</head>
<body>
<!--增加数据的表格-->
<form class="layui-form" >
    <div class="layui-form-item">
        <label class="layui-form-label">券商名称</label>
        <div class="layui-input-block" style="width: 182px">
            <input type="text" name="brokerName" required  lay-verify="required" placeholder="请输入券商名称" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">券商说明</label>
        <div class="layui-input-block" style="width: 182px">
            <input type="text" name="brokerDesc" required  lay-verify="required" placeholder="请输入券商说明" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">券商备注</label>
        <div class="layui-input-block" style="width: 182px">
            <input type="text" name="brokerIntroduce" required lay-verify="required" placeholder="请输入券商备注"
                   autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="addbroker">添加券商</button>
            <button type="reset" class="layui-btn layui-btn-primary" style="background-color: orange; color:aliceblue" >重置</button>
        </div>
    </div>
</form>
<!--表格结束-->
</body>
</html>